
<?php

Loader::using("underscore::libs::Serialization::ArrayToEntityConverter");
require_once 'Validator.php';

/**
 *
 * @author JeyDotC
 */
class RequestBinder {

    private $converter;

    function __construct() {
        $this->converter = new ArrayToEntityConverter();
    }

    public function bind(&$object, $validateData = false) {
        $request = ModulesContext::instance()->getRequest();

        $bindings = $request->post("__bindings");

        if ($validateData) {
            $this->converter->addSubscriber(new Validator());
        }
        $this->converter->convert($bindings, $object);
    }

}

?>
